﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HCFramework.API.LINQ;

namespace HCFramework.Product.Admin.ManufacturerManage
{
    public partial class ChooseManufacturer : System.Web.UI.UserControl
    {
        public int? SelectedID
        {
            set
            {
                cboMain.ClearSelection();
                if (value.HasValue)
                {
                    cboMain.SelectedValue = value.Value + "";
                }
            }
            get
            {
                if (cboMain.SelectedValue == "") return null;
                return int.Parse(cboMain.SelectedValue);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void BindCboData()
        {
            HCDataContext db = new HCDataContext();
            cboMain.DataTextField = "Name";
            cboMain.DataValueField = "ManufacturerID";
            cboMain.DataSource = db.Manufacturers.ToList();
            cboMain.DataBind();
            cboMain.Items.Insert(0,"");
        }
    }
}